package com.ruoyi.cms.service.impl;

import com.ruoyi.cms.domain.CmsTerritory;
import com.ruoyi.cms.mapper.CmsTerritoryMapper;
import com.ruoyi.cms.service.ICmsTerritoryService;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地区层级Service业务层处理
 *
 * @author houyong
 * @date 2025-11-09
 */
@Service
public class CmsTerritoryServiceImpl implements ICmsTerritoryService {
    @Autowired
    private CmsTerritoryMapper cmsTerritoryMapper;

    /**
     * 查询地区层级
     *
     * @param id 地区层级主键
     * @return 地区层级
     */
    @Override
    public CmsTerritory selectCmsTerritoryById(String id) {
        return cmsTerritoryMapper.selectCmsTerritoryById(id);
    }

    /**
     * 查询地区层级列表
     *
     * @param cmsTerritory 地区层级
     * @return 地区层级
     */
    @Override
    public List<CmsTerritory> selectCmsTerritoryList(CmsTerritory cmsTerritory) {
        return cmsTerritoryMapper.selectCmsTerritoryList(cmsTerritory);
    }

    /**
     * 新增地区层级
     *
     * @param cmsTerritory 地区层级
     * @return 结果
     */
    @Override
    public int insertCmsTerritory(CmsTerritory cmsTerritory) {
        cmsTerritory.setCreateTime(DateUtils.getNowDate());
        return cmsTerritoryMapper.insertCmsTerritory(cmsTerritory);
    }

    /**
     * 修改地区层级
     *
     * @param cmsTerritory 地区层级
     * @return 结果
     */
    @Override
    public int updateCmsTerritory(CmsTerritory cmsTerritory) {
        cmsTerritory.setUpdateTime(DateUtils.getNowDate());
        return cmsTerritoryMapper.updateCmsTerritory(cmsTerritory);
    }

    /**
     * 批量删除地区层级
     *
     * @param ids 需要删除的地区层级主键
     * @return 结果
     */
    @Override
    public int deleteCmsTerritoryByIds(String[] ids) {
        return cmsTerritoryMapper.deleteCmsTerritoryByIds(ids);
    }

    /**
     * 删除地区层级信息
     *
     * @param id 地区层级主键
     * @return 结果
     */
    @Override
    public int deleteCmsTerritoryById(String id) {
        return cmsTerritoryMapper.deleteCmsTerritoryById(id);
    }
}
